﻿<?php
session_start();
include("../public_files/conn.php");
date_default_timezone_set("Asia/ShangHai");
$time=date('Y-m-d H:i:s');
$listname_id=$_POST['listname_id'];
$content=$_POST['content'];
$type=$_POST['type'];
$content=deleteHtml($content);
if(isset($_SESSION['userid'])){
	$user_id=$_SESSION['userid'];
}else{
	$user_id=0;
}

if($type==0){
$tabel="official_list_comment";

}else{
$tabel="user_list_comment";
}
/* $listname_id;
$content;
$time;  */
$sql="insert into ".$tabel." (list_id,user_id,content,comment_time) values ('$listname_id','$user_id','$content','$time')";
$result=mysql_query($sql)or die(mysql_error());
if(isset($_SESSION['username'])){
$user_name=$_SESSION['username'];}else{
$user_name="游客";
}
echo '<div class="message_show_1">
																												<!--用户头像-->
							<div class="user_photo_1">
								<img src="../images/user_photo.gif" />
							</div>
																												<!--用户昵称-->
							<div class="user_name_1">
								<a href="#" style="color:#79C3F0;font-size:15px;">'.$user_name.'</a>
								&nbsp;&nbsp;&nbsp;&nbsp;<a style="color:#8996A0;font-size:11px;">'.$time.'</a>
							</div>
																												<!--用户留言内容-->
							<div class="message_show_content"style="width:600px;">
								<p>'.$content.'</p>								
							</div>
						</div>';





?>


<?php
function addHtml($str) { 
	$str = trim($str); 
	//$str = strip_tags($str,""); 
	$str = str_replace("\t","",$str); 
	$str = str_replace("\r\n","<br/>",$str); 
	$str = str_replace("\r","<br/>",$str); 
	$str = str_replace("\n","<br/>",$str); 
	$str = str_replace(" ","&nbsp",$str); 
	return trim($str); 
}
function deleteHtml($str) { 
	$str = str_replace("<br/>","\n",$str); 
	$str = str_replace("&nbsp"," ",$str); 
	return trim($str); 
}
?>

